This guide pertains to the application A Visual Representation of the Saddlepoint Approximation. The code can be found here, and you can use the application here.

I will assume knowledge of exponential tilting and the saddlepoint approximation in this guide – for more information about these topics there is more elaboration in my full thesis which can be found here.

The Scatterplot

Here is what the application looks like on opening:

In the central upper panel, we can see a collection of points. The \(y\)-coordinates of these points follow a Poisson process with rate 1. Independently, the \(x\)-coordinates follow some probability distribution. We can change which distribution this is via the uppermost dropdown box on the left-hand sidebar. The application starts with the points being distributed according to a standard normal density.

Here we are changing the distribution of the \(x\)-coordinates:

The parameters of the distribution can also be changed. This can be done by either clicking and dragging the handle, or by pressing the play and pause buttons below the slider to animate the parameter change:

We can see that doing so does not completely re-simulate the points (i.e. the same seed is used); if this is the aim then the re-simulate button can be pressed:

The controls to the right of the scatterplot change what it looks like:

  • The y range slider is self-explanatory - it allows the user to select the limits of the \(y\) axis
  • The intensity to simulate slider allows the user to specify (approximately) how many points are simulated.
  • The toggle crosshairs allows the user to switch on and off the vertical line which specifies the mean of the distribution
  • The normalise button allows the user to choose whether the points are normalised or not. I will elaborate on this in the next section.

Here I change the controls of the scatterplot:

Changing s

Recall that the saddlepoint approximation at a point \(x\) is found by \(\hat{f}(x) = \dfrac{1}{\sqrt{2\pi K''(s)}}\cdot \exp\left\{K(s)-sx\right\}\) where \(x = K'(s)\) for cumulant generating function \(K(s)\).

In our application we have a slider which changes \(s\). Each point \((x_0,y_0)\) is mapped to \((x_0, y_0e^{-sx_0})\). If normalising is turned on, the mapping is instead from \((x_0, y_0)\) to \((x_0, y_0e^{K(s)-sx_0})\).

Take a look at the video below to see the effect of normalising. If toggled on, the number of points on screen is approximately constant. If not, the number of points will increase as \(s\) increases. In this example, we have a Gamma(2.25, 1.15) distribution.

We can also see from the video above that changing \(s\) also changes the crosshairs on the bottom plot; more on this in the next section.

The Saddlepoint Approx. Plot

With the Gamma(2.25, 1.15) distribution and intensity to simulate set to 100, here is what the lower plot (the saddlepoint approximation plot) looks like:

We can see three lines. The yellow line shows the true density of the distribution on the \(x\)-axis. In this case, this is the Gamma(2.25, 1.15) density plot. The blue line shows the saddlepoint approximation to the true distribution. The black line shows the density of all the points that are simulated (even those that are not visible on the scatterplot).

In the image above, since there are only approximately 100 points simulated, the black line is not a close match to the yellow line. However, as we increase the intensity to simulate, the simulated density converges to the true density.

Each line can be individually toggled via the checkboxes on the right hand side. As for the other controls, the \(y\)-range slider changes the limits of the \(y\) axis, while the toggle log button allows the user to put the \(y\)-axis on a logarithmic scale.

The crosshairs on this plot are also able to be toggled on and off via the toggle crosshairs checkbox. As we’ve seen, these crosshairs change with \(s\). The vertical line shows \(x = K'(s)\), whilst the horizontal line shows the saddlepoint approximation at \(x=K'(s)\).

Here I demonstrate changing the appearance of the saddlepoint approximation plot:

The Tilted Density Plot

To see the tilted plot, we can click on the second tab in the tab box:

Here is what the tilted density plot looks like for the Gamma(2.25, 1.15) distribution:

Just like in the saddlepoint approximation plot, the user is able to toggle on and off each of the lines. There are five lines, so turning them all on at once can be overwhelming. First, let’s talk about the two lines visible in the image above.

  • The tilted distribution draws the true distribution (in this case, the Gamma(2.25, 1.15) distribution) which has been exponentially tilted by the selected value of \(s\). Recall that the probability density function of the \(s\)-tilted density is \(f(x)\exp\{sx − K(s)\}\) where \(f(x)\) is the pdf of the true density.
  • The normal approximation line draws a normal approximation to this tilted distribution. This has the same mean and variance as the tilted density – that is, it has mean \(K'(s)\) and variance \(K''(s)\).

Here are what these two lines look like when we animate an increase in \(s\).

The mean tilted distribution and mean normal distribution lines trace out the mean values of their respective lines, for all values of \(s\). This is easier to explain in video than in words! Here are the normal approximation and mean normal distribution lines toggled on. Note how the former changes with \(s\) but the latter does not.

The final line is the simulated distribution line. This is different to the simulated line in the saddlepoint approximation plot due to the sampling mechanism. In the previous plot, the simulated line includes every simulated point. However, in the tilted distribution plot, the simulated line only shows the density for the visible points in the scatterplot. We have constructed the points in a way which means that the visible points (supposing the intensity to simulate is high enough) approximate the tilted distribution.

If there are insufficient simulated points, such as in the video below, the simulated distribution is not close to the true distribution. Note the red line in the scatterplot representing the maximum value that points can have.

The following video shows the same distribution; this time there is a high intensity to simulate and larger \(y\) range.

The other toggles for this plot - the \(y\) range, log, and crosshairs do the same as the saddlepoint approximation plot. In this case, the centre of the crosshairs point to the peak of the normal approximation to the tilted distribution.

Global Toggles

There are two global toggles at the bottom of the sidebar.

Colourblind mode changes the points so that each colour is also a different shape. It also makes each colour of line a different line style. The \(x\)-range slider changes the limits of the \(x\) axis for all of the three different plots.

The sidebar is also collapsible by clicking on the arrow in the navigation bar!

Choosing K’(s) vs choosing s

So far we have discussed what happens when we change \(s\). In practice, rather than selecting \(s\), it is more useful to select the mean of the tilted distribution, i.e. \(K'(s)\). There is an option in the application to be able to select \(K'(s)\) instead of \(s\); we can see what this looks like here:

Note that at the top of the scatterplot, we can see the values of both \(s\) and \(K'(s)\), no matter the mode that is selected.